import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/home',
    name: 'home',
    component: Home,
    children: [
      {
        path: '/paihangban',
        name: 'Paihangban',
        component: () => import(/* webpackChunkName: "paihangban" */ '../components/DiscovrMusic/Paihangban.vue')
      },
    ]
  },
  // 我的音乐
  {
    path: '/mymusic',
    name: 'Mymusic',
    component: () => import(/* webpackChunkName: "mymusic" */ '../views/Mymusic.vue')
  },
  // 关注
  {
    path: '/focuson',
    name: 'Focuson',
    component: () => import(/* webpackChunkName: "focuson" */ '../views/Focuson.vue')
  },
  // 下载客户端
  {
    path: '/download',
    name: 'Download',
    component: () => import(/* webpackChunkName: "focuson" */ '../views/Download.vue')
  }
]

// 解决重复点击相同路由是会发生报错
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}


const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
